package jcoyote;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * A datatype for commands that can be sent to Q3 based servers.
 *
 * @author Pyrite[1up]
 */
public class Q3Command implements Serializable {

    private String command;
    private String description;
    private String example;
    private int    level ;

    public Q3Command(String cmd, String desc, String ex, int lvl) {
        this.command = cmd;
        this.description = desc;
        this.example = ex;
        this.level = lvl ;
        
        ArrayList t = new ArrayList();
        t.add(new Q3Command("addip", "Adds a players ip address to the banlist and bans them from the server on map change", "addip 255.255.255.255", 0));
        t.add(new Q3Command("bigtext", "Displays large text in the top center portion of players screens.", "bigtext \"1up Mod Rcon\"", 0));
        t.add(new Q3Command("capturelimit", "Sets the amount of flags needed to win a match in a CTF game.", "capturelimit 15", 0));
        t.add(new Q3Command("cmdlist", "Displays a list of commands that can be sent to the server", "cmdlist", 0));
        t.add(new Q3Command("cvarlist", "Displays a list of all available cvar's", "cvarlist", 0));
        t.add(new Q3Command("cyclemap", "Runs the next map in the servers map cycle.", "cyclemap", 0));
        t.add(new Q3Command("dumpuser", "Displays detailed information about a specific player on the server given their client number.", "dumpuser 6", 0));
        t.add(new Q3Command("exec", "Executes a script on the server", "exec clanbot.cfg", 0));
        t.add(new Q3Command("forceteam", "Forces a player to join the red or blue team or forces them into spectator mode given their client number.", "forceteam 8 spectator", 0));
        t.add(new Q3Command("fraglimit", "Sets the amount of kills needed by a player (FFA mode) or team (TDM mode) to win a match.", "fraglimit 100", 0));
        t.add(new Q3Command("guids", "Displays the Globally Unique IDentifier for each player on the server.", "guids", 0));
        t.add(new Q3Command("g_friendlyFire", "Turns friendly fire mode off or on (0 = Off 1 = On).", "g_friendlyFire 0", 0));
        t.add(new Q3Command("g_gametype", "Sets the gametype for the server such as FFA, CTF, TDM. Valid values are between 0-8.", "g_gametype 3", 0));
        t.add(new Q3Command("g_gravity", "Sets the gravity for the server. The default is 800 and lower values mean less gravity.", "g_gravity 800", 0));
        t.add(new Q3Command("g_matchmode", "Matchmode is for matchplay. Features timeouts and ready-commands", "g_matchmode 0", 0));
        t.add(new Q3Command("g_maxteamkills", "Sets the maximum number of times a player can kill a teamate before they are automatically kicked from the server.", "g_maxteamkills 2", 0));
        t.add(new Q3Command("g_nextmap", "Sets the next map to load regardless of the servers mapcycle.", "g_nextmap ut4_casa", 0));
        t.add(new Q3Command("kick", "Kicks a player from the server given their client number.", "kick 3", 0));
        t.add(new Q3Command("map", "Loads a map on the server with a given name.", "map ut4_casa", 0));
        t.add(new Q3Command("mute", "Temporarily mutes a player given their client number.", "mute 12", 0));
        t.add(new Q3Command("nuke", "Rains a grenade down on a player given their client number", "nuke 6", 0));
        t.add(new Q3Command("players", "Displays the current map, player count, and team scores", "players", 0));
        t.add(new Q3Command("reload", "Reload does a complete restart of the current map", "reload", 0));
        t.add(new Q3Command("removeip", "Removes a players ip address from the banlist", "removeip 255.255.255.255", 0));
        t.add(new Q3Command("say", "Displays text on players screens. Does not need quotes around multiple words unlike bigtext", "say 1up ModRcon", 0));
        t.add(new Q3Command("serverinfo", "Displays detailed information about the currently connected server", "serverinfo", 0));
        t.add(new Q3Command("slap", "Slaps a player given their client number", "Slap 8", 0));
        t.add(new Q3Command("status", "Displays basic information about all players on the server.", "status", 0));
        t.add(new Q3Command("timelimit", "Sets the amount of time (in minutes) a map will run before it automatically changes", "timelimit 15", 0));
        t.add(new Q3Command("togglemute", "Mutes a player until they reconnect to the server or until they are unmuted by an administrator.", "togglemute 5", 0));
        t.add(new Q3Command("veto", "Cancels any pending votes that were called.", "veto", 0));
        
    }

    public String getCommand() {
        return this.command;
    }

    public String getDescription() {
        return this.description;
    }

    public String getExample() {
        return this.example;
    }

    public String[] toArray() {
        String[] cmd = {this.command, this.description, this.example };
        return cmd;
    }

    @Override
    public String toString() {
        return this.command;
    }

    public int compareTo(Object o) {
        Q3Command other = (Q3Command)o;
        return this.command.compareTo(other.getCommand());
    }
}